import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { SqlMtmService } from './sql-mtm.service';
import { CreateSqlMtmDto, TagsDto } from './dto/create-sql-mtm.dto';

@Controller('sql-mtm')
export class SqlMtmController {
  constructor(private readonly sqlMtmService: SqlMtmService) { }

  @Post('/create/book')
  create(@Body() createSqlMtmDto: CreateSqlMtmDto) {
    return this.sqlMtmService.create(createSqlMtmDto);
  }

  @Post('/create/tag')
  createTag(@Body() createSqlMtmDto: CreateSqlMtmDto) {
    return this.sqlMtmService.createTag(createSqlMtmDto);
  }

  @Get()
  findAll() {
    return this.sqlMtmService.findAll();
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.sqlMtmService.findOne(+id);
  }

  /**
   * 
   * @param id 
   * @param updateSqlMtmDto 
   * @returns 
   */
  @Patch('/update/tag')
  update(@Body() updateSqlMtmDto: TagsDto) {
    return this.sqlMtmService.updateTag(updateSqlMtmDto);
  }


  @Patch('/update/book')
  updateBook(@Body() updateSqlMtmDto: CreateSqlMtmDto) {
    return this.sqlMtmService.updateBook(updateSqlMtmDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.sqlMtmService.remove(+id);
  }

  @Delete('delete/tag/:id')
  removeTag(@Param('id') id: string) {
    return this.sqlMtmService.removeTag(+id);
  }
}
